//获取当前网址，如： http://localhost:8080/mpts/index.jsp 
var curWwwPath=window.document.location.href; 

//获取主机地址之后的目录如：/mpts/index.jsp 
var pathName=window.document.location.pathname; 
var pos=curWwwPath.indexOf(pathName); 

//获取主机地址，如： http://localhost:8080 
var localhostPaht=curWwwPath.substring(0,pos); 

//获取带"/"的项目名，如：/mpts 
var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);

var basePath = localhostPaht+projectName;
//消息提示
function msgFeedBack(msg,obj){ 
	layer.tips(msg, obj, {
		  tips: [2, 'red'] //可自定义配置颜色
	});
}

function msgPrompt(msg){
	layer.msg(msg, {
		  offset: 't',
		  anim: 1
		},function(){
			toIndex();
		});
}

//加载层
function showLoad(){
	layer.msg('加载中', {
		icon: 16
		,shade: 0.01,
		offset: 't' //坐标
	});
}
function msgAlert(msg){
	layer.alert(msg,{offset:'t'});
}


//时间戳
var timeStamp = Date.parse(new Date());
//格式化日期
function getFormatYMD(timesamp){
	var date = new Date(timesamp);
	Y = date.getFullYear() + '-';
	M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
	D = date.getDate();
	D= D.toString().length==1 ? '0'+D:D;
	return Y+M+D;
}
//计算天数差的函数，通用  
function  DateDiff(sDate1,  sDate2){    //sDate1和sDate2是2002-12-18格式  
    var  aDate,  oDate1,  oDate2,  iDays  
    aDate  =  sDate1.split("-")  
    oDate1  =  new  Date(aDate[1]  +  '-'  +  aDate[2]  +  '-'  +  aDate[0])    //转换为12-18-2002格式  
    aDate  =  sDate2.split("-")  
    oDate2  =  new  Date(aDate[1]  +  '-'  +  aDate[2]  +  '-'  +  aDate[0])  
    iDays  =  parseInt(Math.abs(oDate1  -  oDate2)  /  1000  /  60  /  60  /24)    //把相差的毫秒数转换为天数  
    return  iDays  
}

